package com.prj.ufdm.cloud.feign.fallback;

import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Component;
import com.prj.ufdm.cloud.feign.bpo.NewsBPO;
import com.prj.ufdm.cloud.feign.model.News;

import feign.hystrix.FallbackFactory;

@Component
public class NewsFallback implements FallbackFactory<NewsBPO> {  

	@Override
	public NewsBPO create(Throwable cause) {
		return new NewsBPO() {
			@Override
			public List<News> getNewsList() {
				System.out.println("\n  执行  fallback  Factory ..."+cause); 
				List<News> listNews = new ArrayList<News>();
				News news = new News();
				news.setErrMess(cause.toString());
				listNews.add(news);
				return listNews;
			}
		};
	}
}
